<%@ page language="java"
	import="java.util.*,edu.cnu.tpts.bean.*,edu.cnu.tpts.dao.*,edu.cnu.tpts.dao.impl.*"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/authorize.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



<html>
<head>
	<base href="<%=basePath%>">
    <title>admin</title>
    <link rel="stylesheet" type="text/css" href="/css/main.css">
 
</head>
<body>
<div id="header">

</div>

<div id="menu">
    <ul>

        
        <li><a hidefocus="hidefocus" href="teacher/showTeacher.jsp">查询个人信息</a></li>         
         <li><a hidefocus="hidefocus" href="teacher/updateTeacher.jsp">更新个人信息</a></li>
        <li><a hidefocus="hidefocus" href="teacher/showStudentScore.jsp">学生成绩维护</a></li>
        <li><a hidefocus="hidefocus" href="teacher/predict.jsp">成绩和能力预测</a></li>
        <li><a hidefocus="hidefocus" href="teacher/alarm.jsp">查看预警信息</a></li>
         <li><a hidefocus="hidefocus" href="quit.jsp">退出</a></li>
         	 <%@include file="/WEB-INF/date.jsp"%>
     </ul>
 
</div>

<div class="table">
  
     	<%
    	TeacherDaoImpl teacherDao=new TeacherDaoImpl();
    	Teacher teacher=(Teacher)session.getAttribute("user");
   		teacher=teacherDao.findById(teacher.getId());
   		//teacher=teacherDao.findById(0);
   		String courseStr="'";
   		String couIds=request.getParameter("couIds");
		List<Course>  courseList=teacher.getCourse();

		for(int i=0;i<courseList.size();i++){
			courseStr+=courseList.get(i).getId()+"','";
			
		}
		List<Student> studentList=null;
		
		if(!"'".equals(courseStr))
			courseStr=courseStr.subSequence(0, courseStr.length()-2).toString(); 
		else
			courseStr="''";
		if(null==couIds||"".equals(couIds)||"null".equals(couIds)||"0".equals(couIds)){//如果没有选择课程，查询所有课程的学生
		  couIds="0";
		  studentList=teacherDao.findMyStudentScore(courseStr);
		}else{                                                  ////如果选择课程，查询该课程的学生
		  studentList=teacherDao.findMyStudentScore(couIds);
		}
  
    	 %>

 	
 <br>
   <br>
   <form action="teacher/showStudentScore.jsp" method="post" id="couForm">
   <table>
   	<tr>
   		<td> <select name="couIds"  onchange="document.getElementById('couForm').submit();">
  <option value="0" >全部</option>
  <%for(int i=0;i<courseList.size();i++){ %>
  <option value="<%=courseList.get(i).getId() %>" 
  
  <%if(Integer.parseInt(couIds)==courseList.get(i).getId()){ %>
  selected
  <%} %>
  
  ><%=courseList.get(i).getName() %></option>
  <%} %>
  </select></td>
   	</tr>
   </table>
  
  </form>

  <br/>
    	<table border="1px solid;">
    	<tr>
    	<td>学生编号</td><td>学生名称</td><td>性别</td>
    	<td>所在院系</td><td>所学课程</td><td>平时测验成绩</td>
    	<td>作业成绩</td><td>总成绩</td><td>修改/添加成绩</td><td>清除成绩</td><td>删除学生选课</td></tr>
    	 <%for(Student student:studentList){ 
    	
    	%>
    	<tr>
    	<td><%=student.getId() %></td>
    	<td><%=student.getRealName() %></td>
    	
    	<td><%=student.getSex() %></td>
    	<td><%=student.getStuDepartment() %></td>
    	<td><%=student.getCourseName() %></td>
    	<td>
    	<%=student.getTestScore() %>
    	</td>
    	<td>
    	<%=student.getTaskScore() %>
    	</td>
    	<td>
    	<%=student.getTotalScore() %>
    	</td>
    	<td>
    	<a href="teacher/updateStudentScore.jsp?stuId=<%=student.getId() %>&couId=<%=student.getCouId() %>">修改/添加成绩</a>
    	</td>
    	<td>
    	<a href="teacher/deleteStudentScore.jsp?scoreId=<%=student.getScoreId() %>">清除成绩</a>
    	</td>
    	<td>
    	<a href="teacher/dodeleteStudentCourse.jsp?stuId=<%=student.getId()%>&couId=<%=student.getCouId() %> ">删除学生选课</a>
    	</td>
    	
    	</tr>
    	 	<%} %>
    	</table>
</div>

<div id="copyright">
    <div align="center">
        <font face="Tahoma, Verdana" color="#ffffff">Copyright &copy; 首都师范大学版权所有<br>

            地址：北京市西三环北路105号 100048&nbsp;&nbsp;&nbsp;&nbsp; E-mail: </font><font face="Tahoma, Verdana">

    </font>
    </div>

</div>

</body>
</html>